<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<link rel="stylesheet" type="text/css" href="<{$ipath}>wx/style/request.css" media="all" />
<script type="text/javascript"  src="<{$ipath}>public/js/head.js"></script>
<script type="text/javascript"  src="<{$ipath}>wx/js/jquery.min.js"></script>
<script>
function showwxput(n){
	for(var i=1;i<5;i++){
		$("#putcon"+i).hide();
		$(".ptit i").removeClass("select");
	}
	var temarr=new Array();
	temarr[1]="txt";
	temarr[2]="img";
	temarr[3]="voice";
	temarr[4]="video";
	$("#putcon"+n).show();
	$("#type").val(n);
	$("."+temarr[n]+"icon i").addClass("select");
	$(".wxcancel").attr("onclick","delwxrequest("+n+")");
}
function checkfrm(){
	var type = $("#type").val();
	if(type==1){
		if($("#content").val()=='' || $("#content").val()==null){
			alert('请填写自动回复内容');
			return false;
		}else{
			return true;
		}
	}
}
function delwxrequest(type){
	var url='?g=wx&m=weixin&a=delreg&type='+type;
	$.get(url,function(data){
		if(data=='' || data==null){
			alert('删除失败，请重试');
			return false;
		}
		alert(data.msg);
		if(data.error==1000 || data.error=='1000'){
			$("#putcon"+type).find(".request_item").hide();
			$("#putcon"+type).find(".request_item").remove();
			$("#putcon"+type).find(".request_add").show();
		}
	},'json');
}
function showwxrequest(type,url){
	if(type==2 || type=='2'){
		$("#putcon"+type).find(".request_item").html('<img src="'+url+'" style="max-width:300px" /><a onClick="delmedia(2)">删除图片</a>');
	}else if(type==3 || type=='3'){
		$("#putcon"+type).find(".request_item").html('<audio controls src="'+url+'">您的浏览器不支持H5音频播放</audio><a onClick="delmedia(3)">删除语音</a>');
	}else if(type==4 || type=='4'){
		$("#putcon"+type).find(".request_item").html('<video width="300" controls src="'+url+'">您的浏览器不支持H5视频播放</video><a onClick="delmedia(4)">删除视频</a>');
	}
	$("#putcon"+type).find(".request_item").show();
	$("#putcon"+type).find(".request_add").hide();
}
function delmedia(n){
	$("#putcon"+n).find(".request_item").html('');
	$("#putcon"+n).find(".request_item").hide();
	$("#putcon"+n).find(".request_add").show();
}
</script>
<style>.topnav{ width:94%;margin:0 auto;padding-top:16px;font-size:14px;line-height:18px;}.topnav *{color:#333;}</style>
</head>

<body>
<div class="topnav"><a class="level-1" href="?g=index&m=index&a=platform">我的服务</a>><a class="level-2" href="?g=index&m=index&a=wxpla">微信公众号</a>><span class="level-3">回复设置</span></div>
<div id="wxrequest">
<h1>自动回复设置</h1>
<div class="wxnav">
<ul class="title"><a href="?g=wx&m=weixin&a=rreg"><li class="l select">被添加自动回复</li></a><a href="?g=wx&m=weixin&a=rmsg"><li class="">消息自动回复</li></a><a href="?g=wx&m=weixin&a=rsmart"><li class="r">关键词自动回复</li></a></ul>
<i class="info">公众平台如何设置被添加自动回复</i>
</div>
<div class="wxinput">
<form action="?g=wx&m=weixin&a=rreg" enctype="multipart/form-data" method="post" target="hiddfrm" onSubmit="return checkfrm()">
<ul class="ptit">
<li class="txticon"><a onClick="showwxput(1)"><i class="icon select"></i><span>文字</span></a></li>
<li class="imgicon"><a onClick="showwxput(2)"><i class="icon"></i>图片</a></li>
<li  class="voiceicon"><a onClick="showwxput(3)"><i class="icon"></i>语音</a></li>
<li  class="videoicon"><a onClick="showwxput(4)"><i class="icon"></i>视频</a></li>
</ul>
<ul class="pcon" id="putcon1" style="display:block"><textarea name="content" id="content"><{$view.text.content}></textarea></ul>
<ul class="pcon" id="putcon2">
<div class="hidd request_item" <{if !empty($view.img)}>style="display:block"<{/if}>><img src="<{$view.img.url}>" style="max-width:50%" /> <a onClick="delmedia(2)">删除图片</a></div>
<div class="hidd request_add" <{if empty($view.img)}>style="display:block"<{/if}>>
	<li class="selmate">
    	<a onClick="getmedialist(2)"><i></i>
        <h2 class="space_bottom">从素材库选择</h2></a>
    </li>
    <li class="selmate">
    	<i><input type="file" name="img" class="fhidden" /></i>
        <h2 class="space_bottom">上传图片</h2>
    </li>
</div>
</ul>
<ul class="pcon" id="putcon3">
<div class="hidd request_item"  <{if !empty($view.voice)}>style="display:block"<{/if}>><audio controls src="<{$view.voice.url}>">您的浏览器不支持H5音频播放</audio> <a onClick="delmedia(3)">删除音频</a></div>
<div class="hidd request_add" <{if empty($view.voice)}>style="display:block"<{/if}>>
	<li class="selmate">
    	<a onClick="getmedialist(3)"><i></i>
        <h2 class="space_bottom">从素材库选择</h2></a>
    </li>
    <li class="selmate">
    	<i><input type="file" name="voice" class="fhidden" /></i>
        <h2>上传语音</h2>
        <dd style="margin-bottom:30px;">语音标题：<input type="text" placeholder="请输入语音文件标题" id="title" name="title"  maxlength="20" /></dd>
    </li>
</div>
</ul>
<ul class="pcon" id="putcon4">
<div class="hidd request_item" <{if !empty($view.video)}>style="display:block"<{/if}>><video controls width="300" src="<{$view.video.url}>">您的浏览器不支持H5视频播放</video><a onClick="delmedia(4)">删除视频</a></div>
<div class="hidd request_add" <{if empty($view.video)}>style="display:block"<{/if}>>
<li class="selmate">
    	<a onClick="getmedialist(4)"><i></i>
        <h2 class="space_bottom">从素材库选择</h2></a>
    </li>
    <li class="selmate">
    	<i><input type="file" name="video" class="fhidden" /></i>
        <h2>上传视频</h2>
        <dd>视频标题：<input type="text" placeholder="请输入视频文件标题" name="tit" id="tit"  maxlength="20" /></dd>
        <dd style="margin-bottom:5px;">视频说明：<input type="text" placeholder="请输入视频文件简介" name="desc" id="desc"  maxlength="200" /></dd>
    </li>
</div>
</ul>
<ul class="psubmit"><input type="hidden" id="type" name="type" value="1"><input type="submit" class="wxsubmit" value="保存"> <input type="button" class="wxcancel" onClick="delwxrequest(1)" value="删除回复"></ul>
</form>
</div>
</div>
<div id="shade"></div>
<div id="showmedialist" class="hidddiv">
	<h3>选择素材<em onClick="closeshowmedialist()"><i class="icon_close"></i></em></h3>
    <ul id="showimglist"></ul>
    <ul id="showvoicelist"></ul>
    <ul id="showvideolist"></ul>
    <ul id="shownewslist"></ul>
    <h4><input type="hidden" id="mediashowid" value="" /><input type="hidden" id="mediashowurl" value="" /><input type="hidden" id="selbytype" value="" /><input type="button" class="wxbutton_cancel" id="mediashowsetbutton" value="确认"> <input type="button" class="wxbutton_cancel" onClick="closeshowmedialist()" value="取消" /></h4>
</div>
<script>
function getmedialist(n){
	var url;
	var type;
	var str='';
	var temp='';
	if(n==2){
		type='img';
	}else if(n==3){
		type='voice';
	}else if(n==4){
		type='video';
	}else if(n==5){
		type='news';
	}else{
		alert('选择素材类型错误');
		return false;
	}
	$("#selbytype").val(n);
	url='?g=wx&m=weixin&a=getmedialist&type='+type;
	$.get(url,function(data){
		if(data=='' || data==null){
			str+='<li class="showmedia_nono">暂时没有素材</li>';
		}else{
			if(n==2){
				for(ritem in data){
					str+='<li class="showmedia_img" onclick="setmediashowid(\''+data[ritem].media_id+'\',\''+data[ritem].url+'\',this)"><img src="'+data[ritem].url+'" width="120" height="120" /></li>';
				}
			}else if(n==3){
				for(ritem in data){
					str+='<li class="showmedia_voice" onclick="setmediashowid(\''+data[ritem].media_id+'\',\''+data[ritem].url+'\',this)"><img src="<{$ipath}>wx/images/voice_stop.png" width="60px" onclick="playaudio(this)" /><audio src="'+data[ritem].url+'"></audio><span>'+data[ritem].title+'</span></li>';
				}
			}else if(n==4){
				for(ritem in data){
					str+='<li class="showmedia_video" onclick="setmediashowid(\''+data[ritem].media_id+'\',\''+data[ritem].url+'\',this)"><video src="'+data[ritem].url+'" controls width="200"></video><br>'+data[ritem].title+'<br>'+data[ritem].content+'</li>';
				}
			}else if(n==5){
				alert('参数错误');
			}
			$("#show"+type+"list").append(str);
			$("#shade").show();
			$("#showmedialist").show();
			$("#show"+type+"list").show();
		}
	},'json');
}
function playaudio(obj){
	if($(obj).next("audio").get(0).paused){
		$(obj).next("audio").get(0).play();
		$(obj).attr("src","<{$ipath}>wx/images/voice_play.gif");
	}else{
		$(obj).next("audio").get(0).pause();
		$(obj).attr("src","<{$ipath}>wx/images/voice_stop.gif");
	}
}
function closehidd(){
	$(".hidddiv").hide();
	$("#shade").hide();
}
function setmediashowid(mid,url,obj){
	$("#mediashowid").val(mid);
	$("#mediashowurl").val(url);
	$("#mediashowsetbutton").attr("class","wxbutton");
	$("#mediashowsetbutton").attr("onclick","setmedia()");
	$(obj).parent().find(".icon_issel").remove();
	$(obj).append('<i class="icon_issel"></i>');
}
function setmedia(){
	var type = $("#selbytype").val();
	var media_id=$("#mediashowid").val();
	var url=$("#mediashowurl").val();
	if(type==2){
		$("#putcon2 .request_item").html('<img src="'+url+'" style="max-width:300px" /><input type="hidden" name="media_id2" value="'+media_id+'" /><input type="hidden" name="url2" value="'+url+'" /><a onClick="delmedia(2)">删除图片</a>');
		$("#putcon2 .request_item").show();
		$("#putcon2 .request_add").hide();
	}else if(type==3){
		$("#putcon3 .request_item").html('<audio controls src="'+url+'">您的浏览器不支持H5音频播放</audio><input type="hidden" name="media_id3" value="'+media_id+'" /><input type="hidden" name="url3" value="'+url+'" /><a onClick="delmedia(3)">删除语音</a>');
		$("#putcon3 .request_item").show();
		$("#putcon3 .request_add").hide();
	}else if(type==4){
		$("#putcon4 .request_item").html('<video width="300" controls src="'+url+'">您的浏览器不支持H5视频播放</video><input type="hidden" name="media_id4" value="'+media_id+'" /><input type="hidden" name="url4" value="'+url+'" /><a onClick="delmedia(4)">删除视频</a>');
		$("#putcon4 .request_item").show();
		$("#putcon4 .request_add").hide();
	}else if(type==5){
		alert('暂不支持');
	}
	closeshowmedialist();
}
function closeshowmedialist(){
	$("#shade").hide();
	$("#showmedialist").hide();
	$("#mediashowsetbutton").attr("onclick",'');
	$("#mediashowsetbutton").attr("class","wxbutton_cancel");
	$("#showmedialist").children("ul").html('');
	$("#showmedialist").children("ul").hide();
}
</script>
<iframe width="0" height="0" scrolling="no" frameborder="0" id="hiddfrm" name="hiddfrm" style="display:none"></iframe>
</body>
</html>
